package map;

import java.util.*;

public class MapDemo3 {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        map.put("a", 1);
        map.put("b", 2);
        map.put("c", 3);
        map.put("d", 4);
        map.put("e", 5);
        System.out.println(map);

        Set<String> keyset = map.keySet();
        for(String key : keyset){
            System.out.println(key);
        }


        Collection<Integer> values = map.values();
        for (Integer value : values){
            System.out.println(value);
        }

        Set<Map.Entry<String,Integer>> set = map.entrySet();
        for(Map.Entry<String,Integer> a : set){
            String key = a.getKey();
            Integer value = a.getValue();
            System.out.print(key);
            System.out.println(value);
        }


        keyset.forEach(s->System.out.print(s));
        values.forEach(v-> System.out.println(v));
        set.forEach(entry -> System.out.println("Key: " + entry.getKey() + ", Value: " + entry.getValue()));

    }
}
